package com.hospital.spd.controller;

import com.hospital.spd.pojo.ReportJsonResult;
import com.hospital.spd.pojo.ReportBusinessDO;
import com.hospital.spd.pojo.ReportDetailDO;
import com.hospital.spd.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 报表生成
 * @author heghai
 */
@RestController
@RequestMapping(value = "/report")
public class ReportController {

    @Autowired
    ReportService reportService;

    @GetMapping("/business")
    public ReportJsonResult<Map> business() {
        Map<String,ReportBusinessDO> map = reportService.selectBusiness();
        return new ReportJsonResult<>(0,"success",map.size(),map);
    }


    @GetMapping("/dynamic-data")
    public ReportJsonResult<Map> dynamicData() {
        Map<String,ReportBusinessDO> map = reportService.selectDynData();
        return new ReportJsonResult<>(0,"success",map.size(),map);
    }

    @GetMapping("/return")
    public ReportJsonResult<Map> returnStore() {
        Map<String, List<ReportDetailDO>> map = reportService.selectDetails();
        return new ReportJsonResult<>(0,"success",map.size(),map);
    }

    @GetMapping("/invoice")
    public ReportJsonResult<List> invoice() {
        List<ReportBusinessDO> list = reportService.selectInvoice();
        return new ReportJsonResult<>(0, "success", list.size(), list);
    }
}
